package com.banach.prema.im.callback;


import com.alibaba.fastjson.JSONObject;
import com.banach.prema.im.annotation.Callback;
import com.banach.prema.im.annotation.CallbackCommand;
import com.ego.framework.jdbc.repository.JdbcRepository;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
/**
 * 状态回调服务
 * @author ajun
 *
 */
@Service
@Callback
public class StateCallBackService {
	private final static CallBackResponse SUCCESS_RESPONSE = CallBackResponse.createSuccessResponse();
//	private final static String UPDATE_STATUS_SQL = "update b_app_user set status=? where mobile=?";
	@Resource
	private JdbcRepository jdbcRepository;

	/**
	 *状态变更回调	
	 * @return
	 */
	@CallbackCommand("State.StateChange")
	public CallBackResponse STATE_CHANGE(JSONObject json){
		JSONObject info = json.getJSONObject("Info");
		String identifier = info.getString("Identifier");
		String action = info.getString("Action");
		String status = "Logout".equals(action)?"0":"1";
		//jdbcRepository.update(UPDATE_STATUS_SQL, new Object[]{status,identifier});
		return SUCCESS_RESPONSE;
	}
}
